//
//  UIImage_imageScale.h
//  cardmenNew
//
//  Created by Dengzeyu on 16/1/2.
//  Copyright © 2016年 Dengzeyu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIImage (Scale)
-(UIImage *)TransformtoSize:(CGSize)Newsize;
@end
@implementation UIImage (Scale)


- (UIImage *)TransformtoSize:(CGSize)size {
    
    NSLog(@"%f",[[UIScreen mainScreen] scale]);
    
    // 创建一个bitmap的context
    // 并把它设置成为当前正在使用的context
    //Determine whether the screen is retina

   

         UIGraphicsBeginImageContextWithOptions(size, NO,[[UIScreen mainScreen] scale]);

    // 绘制改变大小的图片
    [self drawInRect:CGRectMake(0, 0, size.width, size.height)];
    // 从当前context中创建一个改变大小后的图片
    UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    // 使当前的context出堆栈
    UIGraphicsEndImageContext();
    // 返回新的改变大小后的图片
    return scaledImage;
    
}

@end